package com.hfjyz.exam.dao;

import java.util.List;

import com.hfjyz.exam.model.UserInfo;

public class UserDaoImpl extends BaseDaoImpl<UserInfo, Integer> implements
		UserDao {

	protected UserDaoImpl() {
		super(UserInfo.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public UserInfo getByIdCardNo(String idCardNo) throws Exception {
		List<UserInfo> users = getHibernateTemplate().find(
				"from UserInfo as user where user.idCardNo = ?",
				new Object[] { idCardNo });
		if (users == null || users.isEmpty()) {
			return null;
		}
		return users.get(0);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<UserInfo> findUserName(String userName) throws Exception {
		return getHibernateTemplate().find(
				"from UserInfo as user where user.name = ?", userName);
	}

}
